﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the API Concepts Framework
 * http://apiconceptsframework.codeplex.com
 *
 * Copyright (C) 2014 eva Kühn, Thomas Scheller, Vienna University of Technology
 * http://www.complang.tuwien.ac.at/eva
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 *
 * ---------------------------------------------------------------- */
#endregion

using System;
using ApiConceptsFramework.Contract;
using ApiConceptsFramework.HCs;

namespace ApiConceptsFramework.FluentApi
{
	/// <summary>
	/// Extension methods for the high-level concept information lookup.
	/// </summary>
	public static class InformationLookupExtensions
	{
		/// <summary>
		/// Defines that the concept requires information lookup. This could be for example, that a method contains a string
		/// parameter that is a filename that needs to be looked up in the file structure (e.g. path of a config file), or
		/// that it is a class or method name that needs to be looked up in another class.
		/// </summary>
		/// <param name="evalAndConcept">The concept to be configured.</param>
		public static void RequiresInformationLookup(this Tuple<ApiEvaluator, ConceptInstance> evalAndConcept)
		{
			RequiresInformationLookups(evalAndConcept, 1);
		}

		/// <summary>
		/// Defines that the concept requires one or more information lookups. This could be for example, that a method contains a string
		/// parameter that is a filename that needs to be looked up in the file structure (e.g. path of a config file), or
		/// that it is a class or method name that needs to be looked up in another class.
		/// The number of lookups could for example depend on the number of method parameters for which a lookup is required.
		/// </summary>
		/// <param name="evalAndConcept">The concept to be configured.</param>
		/// <param name="numberOfLookups">The number of lookups required.</param>
		public static void RequiresInformationLookups(this Tuple<ApiEvaluator, ConceptInstance> evalAndConcept, int numberOfLookups)
		{
			//signalizes that this concept (e.g. method call) requires information that the users needs to look up in an external class
			var pd = evalAndConcept.Item1.GetOrCreateHcInputData<InformationLookupInputData>();
			pd.ConceptsRequiringLookup.Add(new ConceptWithLookup{Concept = evalAndConcept.Item2, NumberOfLookups = numberOfLookups});
		}
	}
}